package com.wos.mpbao.database.dao.impl;

import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;
import static org.springframework.data.mongodb.core.query.Update.update;

import java.util.List;
import java.util.Map;

import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Order;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;

import com.wos.mpbao.bean.Page;
import com.wos.mpbao.database.dao.KhhTestDAO;
import com.wos.mpbao.database.domain.KhhTest;

/**
 * KhhTestDAOImpl
 */
@Repository
public class KhhTestDAOImpl extends CommonDAO implements KhhTestDAO {
	private static String tableName = "KhhTest";
	@Override
	public void save(KhhTest khhTest) {
		
		mongoTemplate.save(khhTest, tableName);
	}

	//删除
	@Override
	public void delete(KhhTest khhTest) {
		mongoTemplate.remove(khhTest, tableName);
	}

	//通过ID查询
	@Override
	public KhhTest selectById(String id) {
		return mongoTemplate.findById(id, KhhTest.class, tableName);
	}

	//查询用户
	@Override
	public List<KhhTest> selectList(Page page) {
		Query query = new Query();
		
		Map<String, Object> param = page.getParam();
		
		
		long totalCount = mongoTemplate.count(query, tableName);
		
		page.setTotalCount((int) totalCount);
		
		List list =  mongoTemplate.find(query.skip(page.getStart()).limit(page.getPageSize()), KhhTest.class, tableName);
		
		page.setResult(list);
		return list;
	}

}
